package com.framework.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.framework.dao.TranTerBenefitInfoDao;
import com.framework.entity.ter.TerMerchantReport;
import com.framework.entity.tran.TranTerBenefitInfo;
import com.framework.entity.tran.TranTransactionInfo;
import com.framework.service.TranTerBenefitInfoService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 机器相关的分润统计
 * @author wq
 */
@Service("tranTerBenefitInfoService")

public class TranTerBenefitInfoServiceImpl extends ServiceImpl<TranTerBenefitInfoDao,TranTerBenefitInfo> implements TranTerBenefitInfoService {



    @Override
    public void addNewRecord(String terBenefitId, TranTransactionInfo info, BigDecimal topOwnBenefit) {
        TranTerBenefitInfo tranTerBenefitInfo=new TranTerBenefitInfo();
        tranTerBenefitInfo.setIsVip(info.getIsVip());
        tranTerBenefitInfo.setTerminalType(info.getTerminalType());
        tranTerBenefitInfo.setTransactionId(info.getTransactionId());
        tranTerBenefitInfo.setTranAmount(info.getAmount());
        tranTerBenefitInfo.setSn(info.getSn());
        tranTerBenefitInfo.setCreateDate(new Date());
        tranTerBenefitInfo.setTerBenefitId(terBenefitId);
        tranTerBenefitInfo.setBenefitAmount(topOwnBenefit);
        baseMapper.insert(tranTerBenefitInfo);


    }


    @Override
    public TranTerBenefitInfo addTranTerBenefitInfo(BigDecimal benefitAmount, TerMerchantReport terMerchantReport, String snBenefitId, TranTransactionInfo tranTransactionInfo) {
        TranTerBenefitInfo benefitInfo= new TranTerBenefitInfo();
        benefitInfo.setTerBenefitId(snBenefitId);
        benefitInfo.setBenefitAmount(benefitAmount);
        benefitInfo.setSn(terMerchantReport.getSn());
        benefitInfo.setTranAmount(tranTransactionInfo.getAmount());
        benefitInfo.setCreateDate(new Date());
        benefitInfo.setTransactionId(tranTransactionInfo.getTransactionId());
        benefitInfo.setTerminalType(tranTransactionInfo.getTerminalType());
        benefitInfo.setIsVip(tranTransactionInfo.getIsVip());
        insert(benefitInfo);
        return benefitInfo;
    }
}

